import React from 'react';
import { Link } from 'react-router-dom';
import Header       from 'component/header/index.jsx';
import AddrDetail       from './addressDetail.jsx';
import appData from '../../util/data.json';
import './address.scss'
class AddrAdd extends React.Component {
    constructor() {
        super();
        this.state = {
            addrObj:{}
        }
    }
    goBack(){
        this.props.history.push('/address');    
    }
    submitDate(data){
        var result=this.checkDate(data);
        if(result.status){
            alert('提交'+JSON.stringify(data))
        }else{
            alert(result.msg)
        }
    }
    checkDate(obj){
        var result = {
            status  : false,
            msg     : ''
        };
        for(var i in obj){
            if(!obj[i]){
                result.msg = '信息未填写完整';
                return result;
            }
        }
        result.status   = true;
        return result;
    }
    render(){

        return(
            <div id='addEdit'>
                  <Header title='新增地址' goBack={e=>{this.goBack(e)}}/>
                  <div className="content bot0 ">
                  <AddrDetail data={this.state.addrObj} submitDate={e=>{this.submitDate(e)}}/>
                  </div>
            </div>
        )
    }
}
export default AddrAdd;